import './assets/main.css'
import 'vant/lib/index.css'
import { createApp } from 'vue'

import App from './App.vue'
import router from './router'
import { tim, TIM } from './tim'
// 导入 Vant 组件
import vant from 'vant'

const app = createApp(App)

// 注册 Vant 组件
app.use(vant)

app.use(router)

// 全局挂载 tim 实例
app.config.globalProperties.$tim = tim

// 监听 SDK ready 状态
function onSDKReady() {
  console.log('SDK is ready')
}
tim.on(TIM.EVENT.SDK_READY, onSDKReady)

// 监听 SDK NOT_READY 状态
function onSDKNotReady() {
  console.log('SDK not ready')
}
tim.on(TIM.EVENT.SDK_NOT_READY, onSDKNotReady)

// 监听被踢下线
function onKickedOut() {
  console.log('被踢下线')
  router.push('/')
}
tim.on(TIM.EVENT.KICKED_OUT, onKickedOut)

app.mount('#app')
